GBML manual / Effects

shroud_cutout_sprite

Makes this instance a light source whose hole is the SHAPE of a sprite you supply, scaled by `scale` - the general form of shroud_cutout, which is just this with a built-in circle. The form without an angle - see shroud_cutout_sprite_angle to also turn the hole.

Works differently on Game Boy - The Game Boy makes a dark room darker and keeps the sprites near a light in their own shades; it cannot light the picture, which has one set of shades. Up to 4 lights. The shape tells which sprites are near.

Works differently on Game Boy Color - The Game Boy Color darkens a dark room and lights the 8 by 8 pixel squares whose middle is under the shape, kept as 4 by 4 pixel blocks. Up to 4 lights, no flicker, a picture of 3 palettes at most and 4 sprite palettes at most.

Works differently on Sega Genesis - The Sega Genesis has one dark level: half as bright as the picture. Every darkness number above 0 shows that same dark (a room set to 72 is no darker than one set to 50), and 0 is no dark at all. A light made from code (shroud_cutout, shroud_cutout_sprite, shroud_cutout_sprite_angle) cuts its hole in that dark. The hole is a picture made ahead of time from the circle or from the sprite the call names, so the sprite's name must be written in the call (not chosen while the game plays), a size or a direction the code works out while the game plays is shown as the nearest one made (six sizes from half to double, sixteen directions), and a size or direction written as a number is exact. Each picture takes cartridge space and some of the picture chip's sprites (the build says how many and refuses a set of lights the chip cannot hold). An object stands in the light as a whole while its middle is in the light, and a light near the edge of the screen is whole or gone.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

shroud_cutout_sprite(mask, scale, flicker)

Arguments

NameType
masksprite
scalereal
flickerbool

Returns

Nothing.

Description

Cuts a hole in the dark of a shrouded room, shaped like a sprite you supply (a cutout mask), rather than a circle. It only cuts a hole in the shroud; it does not light anything by color, and in a room that is not shrouded it does nothing. Any sprite will do, and only its see-through pixels matter. scale sizes it: 1 is the sprite exactly as you drew it, 2 twice as wide and twice as tall. flicker decides whether that pool wavers like a flame or holds steady like a lamp.

This is the form without a rotation - the pool always sits at whatever angle you drew the mask at. If it needs to turn (a flashlight cone following where a character aims, say), use shroud_cutout_sprite_angle instead: the same three arguments, in the same order, plus one more for the angle.

Everything else works exactly like shroud_cutout, which is simply this call with a built-in round mask: the hole follows the instance every frame, a room that is not dark makes it inert rather than wrong, and shroud_cutout(0, false) turns any light back off.

Why a sprite, and why it is the general case

The hole is cut by the hardware, from a sprite's own silhouette - so an arbitrary shape is not an extra feature bolted on top of round lights. It is what the machine was always doing, and a circle is the one shape that comes for free.

That means the mask sprite is never drawn. Nothing asks what color its pixels are, only whether each one is there or not. Two consequences worth knowing before you draw one:

A keyhole, a cone from a lantern, a jagged flicker, a window's rectangle of daylight, a monitor's glow - anything you can draw, you can light with.

Sizing: a multiplier, not a radius

shroud_cutout takes a radius in pixels because a circle has one. A sprite already carries its own width and height, so the only sizing that means anything for an arbitrary shape is "how much bigger or smaller than I drew it" - which is what scale is. Draw the mask at the shape you want, then nudge scale until the pool sits right in the room.

What flicker does here

It pulses the size, the same as it does for shroud_cutout - the pool breathes. It does not walk through the mask sprite's frames; the mask always uses its first frame.

This is on purpose, so that flicker means one thing everywhere, and so that it works with the single-frame mask most people will draw rather than doing nothing until you supply several.

If you want the shape itself to change - genuinely different art, not a different size - call this again with a different sprite from a Step event. You then control exactly when it changes and what it changes to, which is more than a fixed frame order would have given you.

Example

shroud_cutout_sprite(spr_doc_lantern_mask, 1.7, true);

A lantern: the mask sprite's own shape, at a bit under twice the size it was drawn, flickering. In Create, and nothing else is needed - the light belongs to the instance for its whole life and travels with it.

The cost

A scaled light pool uses one of the console's rotation-and-scaling slots for as long as it is lit, which it shares with every other rotated or scaled sprite in the room. See Budgets for the pool they all draw from.

On the GBA

The hole is cut by the GBA’s sprite window, which only ever asks whether a pixel of the mask is transparent - so the mask sprite is never drawn, its colors and palette are irrelevant, and a soft or dithered edge reads as a stippled edge rather than as a gradient. `scale` multiplies the sprite’s own size (1 = as drawn), because a sprite already carries a size and a radius would only mean something for a circle. `flicker` pulses that scale, exactly as it does for shroud_cutout - it never walks through the mask’s frames, and the mask always uses its first frame; for a hole whose SHAPE changes, call this again with a different sprite. Everything else matches shroud_cutout: inert in a room that is not shrouded, the hole follows the instance every frame, calling either one again replaces this instance’s own light rather than adding a second, and `shroud_cutout(0, false)` turns it off. A scaled hole costs one hardware affine matrix while it is live.

See also: shroud_cutoutshroud_cutout_sprite_angleParticles and lightingRoom lighting